/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.raitcon.hibernate.db;

import com.raitcon.hibernate.bean.Departamento;
import com.raitcon.hibernate.factory.HibernateUtil;
import java.util.List;
import org.apache.log4j.Logger;

import org.hibernate.Query;
import org.hibernate.Session;

/**
 *
 * @author Mike
 */
public class DepartamentoDB {
    
//private static final Log log = LogFactory.getLog(DepartamentoDB.class);
  protected static Logger log = Logger.getLogger(DepartamentoDB.class);      
   private Session session=null;
   
   public DepartamentoDB(){
       
       this.session = HibernateUtil.getSessionFactory().getCurrentSession();
   }
    
    
    
    
    
    
    public List getDepartamentoByIdPais(String codPais) {
       
        List<Departamento> dptoList = null;
        try {
            org.hibernate.Transaction tx = session.beginTransaction();
            Query q = session.createQuery ("from Departamento as departamento WHERE cod_Pais ='" +codPais+"'");
            dptoList = (List<Departamento>) q.list();
        } catch (Exception e) {
            log.debug("Error:"+e.getMessage() );
            e.printStackTrace();
        }
        return dptoList;
      }
    
    
   
    
}
